# 自定义 JSON 编码器类
import datetime
import json

import numpy as np
from pydantic_core import to_json

"""
json 编码器
"""
class NumpyJSONEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, np.integer):
            return int(o)
        elif isinstance(o, np.floating):
            return float(o)
        elif isinstance(o, np.ndarray):
            return o.tolist()
        return super().default(o)

"""
获取当前时间str
"""
def get_now_str(format="%Y-%m-%d %H:%M:%S") -> str:
    # 获取当前时间
    current_time = datetime.datetime.now()

    # 以特定格式输出当前时间
    formatted_time = current_time.strftime(format)
    return formatted_time



